package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.mapper.OrdersProjectMapper;
import com.zzyl.service.OrdersProjectservice;
import com.zzyl.vo.NursingProjectVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class OrdersProjectserviceImpl implements OrdersProjectservice {

    @Autowired
    private OrdersProjectMapper ordersProjectMapper;

    /**
     * 分页查询护理项目列表
     * @param name
     * @param status
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageResponse<NursingProjectVo> findByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
//        使用pageHelper设置
        PageHelper.startPage(pageNum,pageSize);
//        进行查询
        List<NursingProjectVo> list = ordersProjectMapper.selectByCondition(name,status);
//        强转page对象
        Page<NursingProjectVo> page = (Page<NursingProjectVo>) list;
        PageResponse<NursingProjectVo> pageResponse = PageResponse.of(page, NursingProjectVo.class);
//        返回PageResponse对象
        return pageResponse;
    }

    /**
     * 根据编号查询护理项目信息
     * @param id
     * @return
     */
    @Override
    public NursingProjectVo findById(Long id) {
        return ordersProjectMapper.selectById(id);
    }
}
